
	<div id="action" class="easyui-dialog" closed="true" style="display:none;">
		<form class="easyui-form">
			<table>

				<tr>
					<td>员工姓名：</td>
					<td>
						<input name='userName' id="userName" type="text" placeholder="输入员工姓名">
					</td>
				</tr>

				<tr>
					<td>密码：</td>
					<td>
						<input name='password' id="password" type="password" placeholder="输入密码">
					</td>
				</tr>

				<tr>
					<td>邮箱：</td>
					<td>
						<input name='email' id='email' type="text" placeholder="输入邮箱">
					</td>
				</tr>

				<tr>
					<td>电话：</td>
					<td>
						<input name='phone' id='phone' type="text" placeholder="输入电话">
					</td>
				</tr>

				<tr>
					<td>角色分配：</td>
					<td id='authority'>

					</td>
				</tr>

				<input type="hidden" name="id" id='id'>

			</table>
		</form>

	</div>

	<script type="text/javascript">

		function submit(id){

			var method = "/adminUser/adminUserAdd";
			if(id > 0){
				var method = "/adminUser/adminUserSaveData";
			}

	        var userName = $("#userName").val();
	        var password = $("#password").val();
	        var email = $("#email").val();
	        var phone = $("#phone").val();
	        var id = $("#id").val();
	        var adminAuthorityId = $("#authority select").val();

	        $.messager.progress({msg:'正在增加...',interval:3000,});
			$.ajax({
				type:"post",
				url:method,
				data:{
					userName:userName,
					password:password,
					email:email,
					phone:phone,
					id:id,
					adminAuthorityId:adminAuthorityId,
				},
				cache: false,
				dataType:'html',
				success:function(data){

					var data = eval('('+data+')');
					if( data.info == 'success' ){
						
						$.messager.progress('close');
						$('#action').dialog('close');
						$('#data').datagrid('reload');
					} else {
						
						$.messager.progress('close');
						$.messager.alert('提示信息', data.info);
					}
				}
			});

		}

		function doAdd(id, data){

			$("#action form").form('reset');

			var title = '新增';
			if(id > 0){
				var title = '修改';
				$("#userName").val(data.userName);
				$("#password").val(data.password);
				$("#email").val(data.email);
				$("#phone").val(data.phone);
				$("#id").val(data.id);
				authority.list(data.adminAuthorityId);

			}else{
				authority.list();
			}

			$('#action').show();
			$('#action').dialog('open').dialog({
				title:title,    
				width:"100%",    
				height:"100%",
				closed:false,    
				cache:false,    
				modal:true,
				closable:true, 
				left:0,
				top:0,
				buttons:[{
					text:'确定',
					width:'56',
					handler:function(){

						submit(id);
					}
				},{
					text:'取消',
					width:'56',
					handler:function(){

						$('#action').dialog('close');
					}
				}],
			});

		}

	</script>
